/**
 * 
 */
package com.shy.config;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.ServletContext;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;
import org.springframework.web.context.ServletContextAware;

import com.shy.base.component.RedisUtil;
import com.shy.base.vo.AppConstants;
import com.shy.portal.entity.SysConfig;
import com.shy.portal.service.SysConfigService;
import com.shy.task.service.TaskEntityService;

import lombok.extern.slf4j.Slf4j;

/**
 * <p>Title:AppContextListener </p>
 * <p>Description:listener系统啟動时執行 </p>
 * <p>Company:ipebg </p> 
 * @author H2013788
 * @date 2019年8月1日
 */
@Slf4j
@Service
public class InitDataListener implements InitializingBean, ServletContextAware{
	
	@Resource
	private SysConfigService sysConfigService;
	
	@Resource
    private TaskEntityService taskEntityService;
	
	@Resource
	private RedisUtil redisUtil;
	
	@Override
    public void afterPropertiesSet() throws Exception {

    }

    @Override
    public void setServletContext(ServletContext servletContext) {
    	//加载配置
    	List<SysConfig> configList = sysConfigService.findAll();
		if(!configList.isEmpty()) {
			for (SysConfig sysConfig : configList) {
				AppConstants.configMap.put(sysConfig.getPropertyName(), sysConfig.getPropertyValue());
			}
		}
		log.error("*******************************system start init************************************");
    }
    
}
